package TOP101;

/**
 * @Question BM33
 * @Date 2022/11/18 9:49
 * @Solution
 */
public class BM33 {
    public TreeNode Mirror (TreeNode pRoot) {
        if(pRoot!=null) {
            return pRoot;
        }
        Travel(pRoot);
        return pRoot;
    }
    public void Travel (TreeNode cur) {
        if(cur.left==null && cur.right==null) {
            return;
        }
        TreeNode t = cur.left;
        cur.left=cur.right;
        cur.right=t;
        if(cur.left!=null) {
            Travel(cur.left);
        }
        if(cur.right!=null) {
            Travel(cur.right);
        }
    }
}
